package org.dizem.groupon.action;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import org.dizem.groupon.Constants;
import org.dizem.groupon.model.domain.ItemEntity;
import org.dizem.groupon.service.ItemService;

import java.util.Map;

/**
 * User: dizem@126.com
 * Time: 11-7-2 下午6:50
 */
public class ShowOrderAction extends ActionSupport {
	private int id;
	private ItemEntity item;
	private ItemService service;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public ItemService getService() {
		return service;
	}

	public void setService(ItemService service) {
		this.service = service;
	}

	public ItemEntity getItem() {
		return item;
	}

	public void setItem(ItemEntity item) {
		this.item = item;
	}

	@Override
	public String execute() throws Exception {
		Map session = ActionContext.getContext().getSession();
		
		if (session.get(Constants.SESSION_USERNAME) == null) {
			return "require_login";

		} else {
			item = service.getById(id);
			return SUCCESS;
		}
	}
}
